#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include<string.h>

int main()
{
    close(1);
    int fd = open("log.txt", O_CREAT | O_WRONLY | O_APPEND, 0666);
    
    //库函数
    printf("Hello printf\n");
    fflush(stdout);

    //系统调用
    const char* msg = "Hello write\n";
    write(fd, msg, strlen(msg));

    close(fd);
    
    return 0;
}
